<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>薪资管理</title>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			$(function(){
				init();
			})
			function init(){
				var reName=$("#reNameset").val();
				var reId = $("#reIdset").val();
				if(reId==""){
						reId=0;	
					}
				$('#tabRemunera').datagrid({    
				    url:'http://127.0.0.1:8080/findRemunera',    
				    method:"post",
				    pagination:true,
				    striped:true,
				    toolbar:"#tb",
				    queryParams:{
						reName:reName,
						reId:reId,
					}
			   });
			   $("#tb").form("reset");
			}
			function caozuo(value,row,index){
				return "<a href='javascript:void(0)' onclick='upd("+index+")' class='easyui-linkbutton'>复核</a>   <a href='javascript:void(0)' onclick='del("+index+")' class='easyui-linkbutton'>删除</a>"
			}
			
			
			
			function zengjia(){
				$("#insertjigou_window").window("open");    
			}
			function addjigoubaocun(){
				var reNameadd = $("#reNameadd").val();
				var reProduceradd = globalData.getEmpeId();
				var reRegistrantadd = globalData.getEmpeId();
				var reDateadd = $("#reDateadd").datebox('getValue');
				var reTypeadd = 1;
				var reJibenadd = $("#reJibenadd").val();
				var rejiaotongadd = $("#rejiaotongadd").val();
				var reTongxunadd = $("#reTongxunadd").val();
				var reFudongadd = $("#reFudongadd").val();
				var reChangguiadd = $("#reChangguiadd").val();
				var reWucanadd = $("#reWucanadd").val();
				var reJiaotongbadd = $("#reJiaotongbadd").val();
				var reChebuadd = $("#reChebuadd").val();
				var reQitaadd = $("#reQitaadd").val();
				var reZongeadd = $("#reZongeadd").val();
				$.post(
					"http://127.0.0.1:8080/saveRemunera", {
						 reName : reNameadd,
						 reProducer : reProduceradd,
						 reRegistrant : reRegistrantadd,
						 reDate : reDateadd,
						 reType : reTypeadd,
						 reJiben : reJibenadd,
						 rejiaotong : rejiaotongadd,
						 reTongxun : reTongxunadd,
						 reFudong : reFudongadd,
						 reChanggui : reChangguiadd,
						 reWucan : reWucanadd,
						 reJiaotongb : reJiaotongbadd,
						 reChebu : reChebuadd,
						 reQita : reQitaadd,
						 reZonge : reZongeadd,
					},
					function(res) {
						if(res>0) {
							alert("增加成功"); 
							$("#insertjigou_window").window("close");
							$("#tabRemunera").datagrid("reload");
						}
					}, "json");
				
				
			}
			function addjigouquxiao(){
				$("#insertjigou_window").window("close");
			}
			
			//修改
			function upd(index) {
				var data = $("#tabRemunera").datagrid("getData");
				var row = data.rows[index]; 
				
				if (row.reType==1) {
					$("#updatejigouForm").form("load", row); 
					$("#updatejigou_window").window("open"); 
				} else{
					alert("已经审核过，请勿再次审核")
				}
				
				
			}
			//删除机构
			function del(index) {
				var data = $("#tabRemunera").datagrid("getData"); 
				var row = data.rows[index]; 
				
				$.messager.confirm('确认', '您确认想要删除记录吗？', function(r) {
					if(r) { 
						$.post("http://127.0.0.1:8080/deleteRemuneraById", {
							reId: row.reId	
						}, function(res) {
							if(res){
								alert("删除成功");
								$("#tabRemunera").datagrid("load");
							}
						});
					}
				});

			}
			function jisuanzonge(){
				var reOpinion = $("#reOpinion").val()*1;
				var rejiaotong = $("#rejiaotong").val()*1;
				var reTongxun = $("#reTongxun").val()*1;
				var reFudong = $("#reFudong").val()*1;
				var reChanggui = $("#reChanggui").val()*1;
				var reWucan = $("#reWucan").val()*1;
				var reJiaotongb = $("#reJiaotongb").val()*1;
				var reChebu = $("#reChebu").val()*1;
				var reQita = $("#reQita").val()*1;
				var reZonge = reOpinion+rejiaotong+reTongxun+reFudong+reChanggui+reWucan+reJiaotongb+reChebu+reQita;
				alert(reZonge)
				$("#reZonge").textbox('setValue',reZonge)
			}
			
			function updjigoubaocun(retype){
				var reDate = $("#reDate").val();
				var reType = retype;
				var reName=$("#reName").val();
				var reJiben = $("#reJiben").val();
				var reId = $("#reId").val();
				var reOpinion = $("#reOpinion").val();
				var rejiaotong = $("#rejiaotong").val();
				var reTongxun = $("#reTongxun").val();
				var reFudong = $("#reFudong").val();
				var reChanggui = $("#reChanggui").val();
				var reWucan = $("#reWucan").val();
				var reJiaotongb = $("#reJiaotongb").val();
				var reChebu = $("#reChebu").val();
				var reQita = $("#reQita").val();
				var reZonge = $("#reZonge").val();
				$.post("http://127.0.0.1:8080/saveRemunera", {
						reId:reId,
						reName:reName,
						reDate:reDate,
						reType : reType,
						reJiben : reJiben,
						rejiaotong : rejiaotong,
						reTongxun : reTongxun,
						reFudong : reFudong,
						reChanggui : reChanggui,
						reWucan : reWucan,
						reJiaotongb : reJiaotongb,
						reChebu : reChebu,
						reQita : reQita,
						reZonge : reZonge,
					},
					function(res) {
						if(res>0) {
							alert("复核成功"); 
							$("#updatejigou_window").window("close");
							$("#tabRemunera").datagrid("reload");
						}
					}, "json");
			}
			function zhuangtai(value, row, index){
				if(value==1){
					return "未审核";
				}else if (value==2) {
					return "正常";
				} else if(value==3){
					return "未通过";
				}else{
					return "未知";
				}
			}
		</script>
	</head>
	
	<body>
		<form id="tb">
			<label for="name">薪资管理</label>  
			<label>薪酬标准编号</label>
			<label><input class="easyui-textbox" type="text"  id="reIdset" ></label>
			<label>薪酬标准名称</label>
			<label><input class="easyui-textbox" type="text"  id="reNameset" ></label>
			<a  href="javascript:void(0)" onclick="init()" class="easyui-linkbutton">查找</a>  	
			<a  href="javascript:void(0)" onclick="zengjia()" class="easyui-linkbutton">增加新标准</a>  	
		</form>
		<table id="tabRemunera" class="easyui-datagrid" style="width:400px;">
			<thead>
				<tr>
					<th data-options="field:'reId',title:'序号',align:'center'"></th>
					<th data-options="field:'reName',title:'薪酬项目名称'"></th>
					<th data-options="field:'reZonge',title:'总金额'"></th>
					<th data-options="field:'reType',formatter:zhuangtai">状态</th>
					<th data-options="field:'caozuo',title:'操作',align:'center',formatter:caozuo"></th>
				</tr>
			</thead>
		</table>
		<div id="insertjigou_window" class="easyui-window" title="增加新的" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:1000px;height:400px;padding:10px;">
			<table>
				<tr>
					<th>薪酬标准编号</th>
					<th><input class="easyui-textbox" type="text"  id="jNameadd" name="jName"></th>
					<th>薪酬标准名称</th>
					<th><input class="easyui-textbox" type="text"  id="reNameadd" name="reName"></th>
					<th>薪酬标准总额</th>
					<th><input class="easyui-textbox" type="text"  id="reZongeadd" name="reZonge">
					<a href="javascript:void(0)" class="easyui-linkbutton" onclick="jisuanzonge()">计算总额</a>
					</th>
				</tr>
				<tr>
					<th>制定人</th>
					<th><input class="easyui-textbox" type="text"  id="reProduceradd" name="reProducer"></th>
					<th>登记人</th>
					<th><input class="easyui-textbox" type="text"  id="reRegistrantadd" name="reRegistrant"></th>
					<th>登记时间</th>
					<th>
					<input  id="reDateadd" type= "text"   class= "easyui-datebox" name="reDate"></th>
				</tr>
				<tr>
					<th>序号</th>
					<th>薪酬项目名称</th>
					<th></th>
					<th>金额</th>
				</tr>
				<tr>
					<th>1</th>
					<th>基本工资</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reJibenadd" name="reJiben"></th>
				</tr>
				<tr>
					<th>2</th>
					<th>交通补贴</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="rejiaotongadd" name="rejiaotongadd"></th>
				</tr>
				<tr>
					<th>3</th>
					<th>通讯补贴</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reTongxunadd" name="reTongxun"></th>
				</tr>
				<tr>
					<th>4</th>
					<th>浮动工资</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reFudongadd" name="reFudong"></th>
				</tr>
				<tr>
					<th>5</th>
					<th>常规</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reChangguiadd" name="reChanggui"></th>
				</tr>
				<tr>
					<th>6</th>
					<th>午餐补助</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reWucanadd" name="reWucan"></th>
				</tr>
				<tr>
					<th>7</th>
					<th>交通补助</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reJiaotongbadd" name="reJiaotongb"></th>
				</tr>
				<tr>
					<th>8</th>
					<th>车补</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reChebuadd" name="reChebu"></th>
				</tr>
				<tr>
					<th>9</th>
					<th>其他</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0"  id="reQitaadd" name="reQita"></th>
				</tr>
				<tr>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="addjigoubaocun()">保存</a></th>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="addjigouquxiao()">取消</a></th>
				</tr>
			</table>
		</div>	
		<div id="updatejigou_window" class="easyui-window" title="修改机构信息" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:1000px;height:400px;;padding:10px;">
			<form id="updatejigouForm">
				<table>
				<tr>
					<th>薪酬标准编号</th>
					<th><input class="easyui-textbox" type="text" disabled="disabled"  id="reId" name="reId"></th>
					<th>薪酬标准名称</th>
					<th><input class="easyui-textbox" type="text"  id="reName" name="reName"></th>
					<th>薪酬标准总额</th>
					<th><input class="easyui-textbox" type="text"  id="reZonge" name="reZonge"></th>
				</tr>
				<tr>
					<th>制定人</th>
					<th><input class="easyui-textbox" type="text"  id="reProducer" name="reProducer"></th>
					<th>登记人</th>
					<th><input class="easyui-textbox" type="text"  id="reRegistrant" name="reRegistrant"></th>
					<th>登记时间</th>
					<th><input class="easyui-textbox" type="text" disabled="disabled"  id="reDate" name="reDate">
					
					</th>
				</tr>
				<tr>
					<th>复核意见</th>
					<th><input class="easyui-textbox" type="text"  id="reOpinion" name="reOpinion"></th>
					<th></th>
					</tr>
				<tr>
					<th>序号</th>
					<th>薪酬项目名称</th>
					<th></th>
					<th>金额</th>
				</tr>
				<tr>
					<th>1</th>
					<th>基本工资</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reJiben" name="reJiben"></th>
				</tr>
				<tr>
					<th>2</th>
					<th>交通补贴</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="rejiaotong" name="rejiaotongadd"></th>
				</tr>
				<tr>
					<th>3</th>
					<th>通讯补贴</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reTongxun" name="reTongxun"></th>
				</tr>
				<tr>
					<th>4</th>
					<th>浮动工资</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reFudong" name="reFudong"></th>
				</tr>
				<tr>
					<th>5</th>
					<th>常规</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reChanggui" name="reChanggui"></th>
				</tr>
				<tr>
					<th>6</th>
					<th>午餐补助</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reWucan" name="reWucan"></th>
				</tr>
				<tr>
					<th>7</th>
					<th>交通补助</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reJiaotongb" name="reJiaotongb"></th>
				</tr>
				<tr>
					<th>8</th>
					<th>车补</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0" id="reChebu" name="reChebu"></th>
				</tr>
				<tr>
					<th>9</th>
					<th>其他</th>
					<th></th>
					<th><input class="easyui-textbox" type="text" value="0"  id="reQita" name="reQita"></th>
				</tr>
				<tr>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="updjigoubaocun(2)">复核通过</a></th>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="updjigoubaocun(3)">复核不通过</a></th>
				</tr>
			</table>
			</form>
		</div>		
	</body>
</html>
